<?php
class FrmTableUsers{
	private $setter;
	private $dbOperator;
	private $dbConsult;
		
	function FrmTableUsers(){
		$this->dbConsult="SELECT id, nombre, apellido, nick, telefono, direccion, email, idRol FROM usuarios";
		$this->setter=new Setter("../Config");
		
		$this->dbOperator=new DbOperator($this->setter->getDataBaseHost(),$this->setter->getDataBaseUserName(),$this->setter->getDataBaseName(),$this->setter->getDataBasePassword());
		$this->dbOperator->connect();
		$this->dbOperator->consult($this->dbConsult,"yes");
		$this->dbOperator->addIcon("editar","editar","editar","editar usuario","../Themes/".$this->setter->getTheme()."/Images/editar.png","Editar este usuario","button",array("onclick"=>"tableInfoPOSTMethodSend(this.id,this.value,'tableUsers','../Events/EventsFrmTableUsers.php')"));
		$this->dbOperator->addIcon("eliminar","eliminar","eliminar","eliminar usuario","../Themes/".$this->setter->getTheme()."/Images/eliminar.png","Eliminar este usuario","button",array("onclick"=>"tableInfoPOSTMethodSend(this.id,this.value,'tableUsers','../Events/EventsFrmTableUsers.php')"));
		$this->dbOperator->addIcon("masInfo","masInfo","masInfo","ver más información de este usuario","../Themes/".$this->setter->getTheme()."/Images/info.png","Ver más sobre este usuario","button",array("onclick"=>"tableInfoPOSTMethodSend(this.id,this.value,'tableUsers','../Events/EventsFrmTableUsers.php')"));
		$this->dbOperator->setReceptorName("tableUsers");
	}
	function setDbConsult($dbConsult="SELECT id, nombre, apellido, nick, telefono, direccion, email, idRol FROM usuarios"){
		$this->dbConsult=$dbConsult;	
		$this->dbOperator->consult($this->dbConsult,"yes");	
	}
	function getDbConsult(){
		return $this->dbConsult;
	}
	
	function show(){
		//Cambio de presentación de ids por sus respectivos nombres :)
		$rowVals=$this->dbOperator->getRowValues();
		for ($k=7; $k<=count($rowVals);$k=$k+8){
			$nombreId=$this->dbOperator->consult("SELECT nombre FROM roles WHERE id='".$rowVals[$k]."'","yes");
			$rowVals[$k]=$nombreId[0];
		}
		$this->dbOperator->setRowValues($rowVals);
		//-----------------------------------------------------------		
		$this->dbOperator->show($eventsFile="../Events/EventsFrmTableUsers.php", $titles=array("id","Nombre", "Apellido", "Nick", "Telefono", "Direccion", "Email", "Rol"), $colFormats=array(),$colKey=0, $titleButtons="yes");
	}
}
?>